package patrol.mobile.com.mobilepatrol.persenter;

import com.zhy.http.okhttp.callback.StringCallback;

import java.util.Map;

import okhttp3.Call;
import patrol.mobile.com.mobilepatrol.api.HttpUtils;
import patrol.mobile.com.mobilepatrol.response.ImgResponse;
import patrol.mobile.com.mobilepatrol.utils.GsonUtil;
import patrol.mobile.com.mobilepatrol.view.ImgView;

/**
 * Created by apple on 17/9/28.
 */

public class ImgPer {
    private ImgView mView;

    public ImgPer(ImgView mView) {
        this.mView = mView;
    }

    public void getBridgeImg(String url, Map<String,String> map){
        HttpUtils.post(url,map).execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                mView.onImgError();
            }

            @Override
            public void onResponse(String response, int id) {
                ImgResponse imgResponse = GsonUtil.GsonToBean(response,ImgResponse.class);
                if (imgResponse.state==200){
                    mView.onImgSuccess(imgResponse.result);
                }else{
                    mView.onImgError();
                }

            }
        });
    }
}
